<template>
  <div>
    <el-form style="margin: 20px 0" ref="queryForm" size="small" :inline="true"  label-width="68px">
      <el-form-item label="标题" prop="location">
        <el-input
          placeholder="请输入标题"
          clearable
        />
      </el-form-item>
      <el-form-item label="位置" prop="location">
        <el-input
          placeholder="请输入位置"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" >搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini">重置</el-button>
      </el-form-item>
    </el-form>
    <div>
      <div class="item" v-for="item in dataList" @click="goto(item.id)">
        <el-image :src="item.images[0].url" class="top"></el-image>
        <div class="bottom">
          <div>{{item.title}}</div>
          <div style="font-size: 13px;color: #475669">{{item.time}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.item {
  margin: 20px 0 20px 10%;
  width: 20%;
  height: 200px;

  float: left;
  .top {
    height: 160px;
    width: 100%;
    border-radius: 15px;
  }
  .bottom {
    height: 40px;
  }
}
</style>

<script>
import {getProList} from "@/api/distrack/distrack";

export default {
  name: "DistrackShowList",
  data() {
    return {
      dataList: []
    };
  },
  created() {

  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      await getProList().then(response => {
        this.dataList = response.data.map(item => {
          // 将 item.images 字段从 JSON 字符串转换为对象数组
          item.images = JSON.parse(item.images);
          return item;
        });
      })
    },
    goto(id) {
      this.$router.push({path: '/distrack/show', query: {id: id}})
    }
  }
};
</script>
